import "./_style.scss";
import { useEffect, useState } from "react";
import { useParams } from "react-router";
import { getArticle } from "../../../api/api";

const Index = () => {
  const {id: artId} = useParams();
  const [article, setArticle] = useState({});
  useEffect(() => {
    getArticle({id: artId}).then(res => {
      setArticle(res.article);
    });
  }, [artId]);
  return (
    <div className="index">
      <h2 className="title">
        {article.title}
      </h2>
      <p className="sub_title">
        <sapn className="type">
          分类: {article.typeName}
        </sapn>
        <span className="auth">
          作者: {article.authName}
        </span>
        <span className="time">
          发表时间: {article.createdAt}
        </span>
      </p>
      <p className="article_container" dangerouslySetInnerHTML={{__html: article.content}}></p>
    </div>
  );
}

export default Index;